package com.five.controller;

import com.five.pojo.Club;
import com.five.pojo.ClubJoin;
import com.five.pojo.PageBean;
import com.five.pojo.Result;
import com.five.service.ClubService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lenovo
 */
@Tag(name = "社团接口")
@RestController
@RequestMapping("/club")
public class ClubController {
    @Autowired
    ClubService clubService;
    @Operation(summary = "获取全部社团信息")
    @GetMapping("/clubInfo")
    public Result getAllClub(){
        List<Club> list = clubService.getAll();
        return Result.success(list);
    }
    //分页
    @Operation(summary = "按条件查询分页")
    @GetMapping("/page")
    public Result page(@RequestParam(defaultValue = "1") Integer page ,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       String  cName , String cType)
    {
        PageBean pageBean = clubService.page(page , pageSize , cName , cType);
        return Result.success(pageBean);
    }

    //申请入团
    @Operation(summary = "申请入团")
    @PostMapping("/add")
    public Result add(@RequestBody ClubJoin clubJoin)
    {
        clubService.addClub(clubJoin);
        return Result.success();
    }

    //查询入团申请信息
    @Operation(summary = "查询入团申请信息")
    @GetMapping("/getJoinInfo")
    public Result getJoinInfo(){
        List<ClubJoin> list = clubService.getAllJoin();
        return Result.success(list);
    }
}
